﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SmartProduction.Domain.ProductionOrders;
using SmartProduction.Domain.Ptoduction;
using SmartProduction.Domain.采购委外订单;
using SmartProduction.ErrorCode;
using SmartProduction.Read.API.Application.Commands.BasicList;
using SmartProduction.Read.API.Application.Commands.SCWorkCommand;
using SmartProduction.Read.API.Dto;

namespace SmartProduction.Read.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class WorkOrderController : ControllerBase
    {
        /// <summary>
        /// 中介者
        /// </summary>
        private readonly IMediator mediator;
        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="mediator"></param>
        public WorkOrderController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 查询生产工单单号
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIPaing<List<AssociatedProductionOrder>>> GetSCDanHao([FromQuery] SCDanHaoQuerycommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        ///查询生产工单的物品名称列表
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIPaing<List<item_classification_detail>>> GetWuPinname([FromQuery] SCWuPinQueryCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 查询生产工单列表
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]

        public async Task<APIPaing<List<SCWorkOrderDtos>>> GetSCWorkOrder([FromQuery] SCWorkOrderQueryCommand request)
        {
            try
            {

                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 查询工序流程
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]

        public async Task<APIPaing<List<ProcessFlowSheet>>> GetSCWorkOrderLC([FromQuery]SCLCQueryCommand request)
        {
            try
            {

                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 查询生产工单详情列表
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]

        public async Task<APIPaing<List<SCWorkOrderXQDtos>>> GetSCWorkOrderXQ([FromQuery]SCWorkOrderXQQueryCommand request)
        {
            try
            {

                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 工艺路线显示
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIPaing<List<ProcessRoute>>> GetSCLuXian([FromQuery] SCLXQueryCommand request, CancellationToken cancellationToken)
        {
            try
            {

                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }


        /// <summary>
        /// 质检显示
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIPaing<List<Basicinformation>>> BasicinfoList([FromQuery]zhijianBasicListCommand request)
        {
            try
            {

                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
